package com.yenlien.traceyun.control.controller;

import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.control.service.rest.ResourceRestService;
import com.yenlien.traceyun.webase.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by LiuSha on 2020/8/14.
 */
@RestController
@RequestMapping("/resource")
public class ResourceController extends BaseController {
    @Autowired
    private ResourceRestService resourceRestService;

    /**
     * 加载app对应的资源
     *
     * @return
     */
    @RequestMapping(value = "/findByAppId/{appId}", method = RequestMethod.GET)
    public Object findByAppId(@PathVariable("appId") String appId) {
        return resourceRestService.findByAppId(appId);
    }


    /**
     * 加载app对应的资源
     *
     * @return
     */
    @RequestMapping(value = "/findCustomAppVersion/{customAppVersionId}", method = RequestMethod.GET)
    public Object findByCustomAppVersionId(@PathVariable("customAppVersionId") String customAppVersionId) {
        return resourceRestService.findByCustomAppVersion(customAppVersionId);
    }


    /**
     * 新增app对应的资源
     *
     * @return
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Object save(@RequestBody JSONObject jsonObject) {
        return resourceRestService.save(jsonObject);
    }
}
